package org.example.new_hbps_backend_reconstruction.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.new_hbps_backend_reconstruction.entity.StepCountLogsEntity;
import org.example.new_hbps_backend_reconstruction.mapper.StepCountLogsMapper;
import org.example.new_hbps_backend_reconstruction.service.StepCountLogsService;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * @author 丁利军
 * @date 2025年10月15日 21:35
 * @description 有关步数的service层实现类
 */

@Service
public class StepCountLogsServiceImpl extends ServiceImpl<StepCountLogsMapper, StepCountLogsEntity>
        implements StepCountLogsService {

    @Resource
    private StepCountLogsMapper stepCountLogsMapper;

    @Override
    public StepCountLogsEntity getLatestByPatientUid(Long patientUid) {
        return stepCountLogsMapper.findLatestByPatientUid(patientUid);
    }

    @Override
    public IPage<StepCountLogsEntity> getPageByPatientUid(Long patientUid, int pageNum, int pageSize) {
        Page<StepCountLogsEntity> page = new Page<>(pageNum, pageSize);
        return stepCountLogsMapper.selectPageByPatientUid(page, patientUid);
    }

    @Override
    public List<StepCountLogsEntity> getByPatientUidAndDate(Long patientUid, LocalDate date) {
        return stepCountLogsMapper.findByPatientUidAndDate(patientUid, date);
    }

    @Override
    public List<StepCountLogsEntity> getAllByPatientUid(Long patientUid) {
        return stepCountLogsMapper.findAllByPatientUid(patientUid);
    }
}

